var Http = require('../utils/Http');
function DataSource(url, data, method) {
    this._className = 'DataSource';
    this._url = url;
    this._data = data;
    this._method = method;
}

DataSource.prototype.request = function (url, data, method){
    var _url = url || this._url,
        _data = data || this._data,
        _method = method || this._method||'GET';
    return Http[method.toLowerCase()](url, data);
}

DataSource.prototype.refresh = function (){
    this.request();
}

module.exports = {
    init: function (url, data, method){
        return DataSource(url, data, method);
    },
    post: function (url, data){
        return DataSource(url, data, "POST");
    },
    get: function (url, data){
        return DataSource(url, data, "GET");
    }
}
